/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.jr2tecnologia.model.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author ronildo
 */
@Entity
@Table(name = "credit")
@NamedQueries({
    @NamedQuery(name = "Credit.findAll", query = "SELECT c FROM Credit c"),
    @NamedQuery(name = "Credit.findByPkCredit", query = "SELECT c FROM Credit c WHERE c.pkCredit = :pkCredit"),
    @NamedQuery(name = "Credit.findByValue", query = "SELECT c FROM Credit c WHERE c.value = :value"),
    @NamedQuery(name = "Credit.findByDescription", query = "SELECT c FROM Credit c WHERE c.description = :description"),
    @NamedQuery(name = "Credit.findByDatetimeRegistered", query = "SELECT c FROM Credit c WHERE c.datetimeRegistered = :datetimeRegistered")})
public class Credit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "pk_credit")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_credit")
    @SequenceGenerator(name="seq_credit", sequenceName="seq_credit", allocationSize=1)
    private Long pkCredit;

    @Basic(optional = false)
    @Column(name = "value")
    private Double value;

    @Basic(optional = false)
    @Column(name = "description")
    private String description;

    @Basic(optional = false)
    @Column(name = "datetime_registered")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datetimeRegistered;
    
    @JoinColumn(name = "fk_bank_account", referencedColumnName = "pk_bank_account")
    @ManyToOne(optional = false)
    private BankAccount bankAccount;

    public Credit() {
    }

    public Credit(Long pkCredit) {
        this.pkCredit = pkCredit;
    }
    
    public Credit(BankAccount bankAccount) {
        this.bankAccount = bankAccount;
    }

    public Credit(Long pkCredit, Double value, String description, Date datetimeRegistered) {
        this.pkCredit = pkCredit;
        this.value = value;
        this.description = description;
        this.datetimeRegistered = datetimeRegistered;
    }

    public Long getPkCredit() {
        return pkCredit;
    }

    public void setPkCredit(Long pkCredit) {
        this.pkCredit = pkCredit;
    }

    public Double getValue() {
        return value;
    }

    public void setValue(Double value) {
        this.value = value;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getDatetimeRegistered() {
        return datetimeRegistered;
    }

    public void setDatetimeRegistered(Date datetimeRegistered) {
        this.datetimeRegistered = datetimeRegistered;
    }

    public BankAccount getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(BankAccount bankAccount) {
        this.bankAccount = bankAccount;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pkCredit != null ? pkCredit.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Credit)) {
            return false;
        }
        Credit other = (Credit) object;
        if ((this.pkCredit == null && other.pkCredit != null) || (this.pkCredit != null && !this.pkCredit.equals(other.pkCredit))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.jr2tecnologia.model.entity.Credit[pkCredit=" + pkCredit + "]";
    }

}
